import 'package:flutter/material.dart';
import 'package:myfirstflutter/utils/common_color.dart';

class MinePageWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new MinePageWidgetState();
  }
}

class MinePageWidgetState extends State<MinePageWidget>
    with AutomaticKeepAliveClientMixin {
  List<String> _items;

  @override
  bool get wantKeepAlive => true;

  @override
  void initState() {
    super.initState();
    _items = ['企业信息', '报修记录', '服务申请记录', '投诉建议', '物业联系电话'];
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return new Scaffold(
      backgroundColor: Colors.white,
      body: ListView(
        children: <Widget>[
          _topCard(),
          new Container(
            height: 15,
            color: backGrayColor,
          ),
          new Container(
            height: 45.0 * (_items.length + 2),
            child: new ListView.separated(
              separatorBuilder: (BuildContext context, int index) =>
                  new Divider(
                indent: 24,
              ),
              itemBuilder: (BuildContext context, int index) {
                return new Container(
                  height: 45.0,
                  padding: EdgeInsets.only(left: 25, right: 25),
                  child: new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(_items[index]),
                      (index == _items.length - 1)
                          ? Text('0571-88888888')
                          : Image.asset(
                              'images/zone_right.png',
                              width: 6,
                              height: 12,
                            )
                    ],
                  ),
                );
              },
              itemCount: _items.length,
            ),
          )
        ],
      ),
    );
  }

  Widget _topCard() {
    return new Container(
        height: 200,
        alignment: Alignment(0.0, 0.6),
        decoration: new BoxDecoration(color: Colors.white, boxShadow: [
          BoxShadow(color: offsetGrayColor, offset: Offset(0.0, 1.0)),
        ]),
        child: Container(
          height: 120,
          child: new Column(
            children: <Widget>[
              Container(
                width: 175,
                height: 100,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage("images/mine_back.png"),
                    fit: BoxFit.cover,
                  ),
                ),
                child: Center(
                  child: new Image.asset(
                    "images/mine_profile.png",
                    width: 60,
                    height: 60,
                  ),
                ),
              ),
              Text('联通（浙江）产业互联网有限公司')
            ],
          ),
        ));
  }
}
